import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';

import 'get_widget_dialog_controller.dart';

class GetWidgetDialogWidget extends StatelessWidget {
  final controller = Get.put(GetWidgetDialogController());
  String title;
  String message;
  String? cancelText;
  String? confirmText;
  GestureTapCallback? onCancelEvent;
  GestureTapCallback? onConfirmEvent;

  GetWidgetDialogWidget({
    required this.title,
    required this.message,
    this.cancelText,
    this.confirmText,
    this.onCancelEvent,
    this.onConfirmEvent,
  });

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async => true,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          GFAlert(
            title: title,
            content: message,
            type: GFAlertType.rounded,
            contentTextStyle: const TextStyle(
              color: Colors.black87,
              fontSize: 17,
              fontWeight: FontWeight.w500,
              decoration: TextDecoration.none,
            ),
            titleTextStyle: const TextStyle(
              color: Colors.black87,
              fontSize: 17,
              fontWeight: FontWeight.w500,
              decoration: TextDecoration.none,
            ),
            bottombar: Row(
                mainAxisAlignment: confirmText != null && cancelText != null
                    ? MainAxisAlignment.end
                    : MainAxisAlignment.center,
                children: <Widget>[
                  Visibility(
                    visible: cancelText != null && cancelText!.isNotEmpty,
                    child: GFButton(
                        onPressed: onCancelEvent,
                        shape: GFButtonShape.pills,
                        color: Colors.grey[300]!,
                        child: Text(cancelText ?? "",
                            style: const TextStyle(color: Colors.black))),
                  ),
                  const SizedBox(width: 5),
                  Visibility(
                      visible: confirmText != null && confirmText!.isNotEmpty,
                      child: GFButton(
                        onPressed: onConfirmEvent,
                        shape: GFButtonShape.pills,
                        text: confirmText,
                      ))
                ]),
          ),
        ],
      ),
    );
  }
}
